import {I18Parse,CommonLang} from '@lowcode/jpaas-base-lib';
import {formControlLanguage} from '@lowcode/jpaas-form-lib';
import { ShareComponentLang} from '@lowcode/jpaas-share-component';
import { fullcalendarLang} from '@lowcode/rx-fullcalendar';

let i18LangUtil = {
    jsFiles :import.meta.globEager("./impl/**/*.js")
};

i18LangUtil.langeFilesHandler =function(langKey){
    let obj ={};
    let commonLang=I18Parse.langeHandler(CommonLang,langKey);
    if(formControlLanguage){
        obj["formControlLanguage"]=I18Parse.langeHandler(formControlLanguage,langKey)
    }
    if(fullcalendarLang){
        obj["fullcalendarLang"]=I18Parse.langeHandler(fullcalendarLang["fullcalendarLang"],langKey)
    }
    if(ShareComponentLang){
        obj["shareComponentLang"]=I18Parse.langeHandler(ShareComponentLang["shareComponentLang"],langKey)
    }
    obj = { ...obj,...commonLang };
    for (const key in i18LangUtil.jsFiles) {
        let json = i18LangUtil.jsFiles[key].default;
        let jsonLang=I18Parse.langeHandler(json,langKey);
        obj = { ...obj,...jsonLang };
    }
    return obj;
}

export default i18LangUtil;
